﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using eTMS.Services;

namespace eTMS.WindowServices
{
    public class ServiceEntry
    {

        private List<ServiceHost> listServices = new List<ServiceHost>();

        private void AddService(ServiceHost service)
        {
            listServices.Add(service);
            service.Open();
            //progress.Increment(1);
            // Application.DoEvents();
        }

        public void StartServices()
        {
            ServiceHost service;
            service = new ServiceHost(typeof(GiangVienLopTinChiService));
            AddService(service);

            service = new ServiceHost(typeof(GiaoVienNgayNghiService));
            AddService(service);

            service = new ServiceHost(typeof(PhongHocNgayNghiService));
            AddService(service);

            service = new ServiceHost(typeof(ThoiGianGiangDayService));
            AddService(service);
            service = new ServiceHost(typeof(ApDungChuongTrinhDaoTaoService));
            AddService(service);

            service = new ServiceHost(typeof(BoMonService));
            AddService(service);

            service = new ServiceHost(typeof(CachChonSinhVienCamThiService));
            AddService(service);

            service = new ServiceHost(typeof(CachTinhHocBongService));
            AddService(service);

            service = new ServiceHost(typeof(CaHocService));
            AddService(service);

            service = new ServiceHost(typeof(CanBoLopService));
            AddService(service);

            service = new ServiceHost(typeof(CategoriesService));
            AddService(service);

            service = new ServiceHost(typeof(ChiPhiDaoTaoService));
            AddService(service);

            service = new ServiceHost(typeof(ChiTietChuongTrinhService));
            AddService(service);

            service = new ServiceHost(typeof(ChucVuCanBoLopService));
            AddService(service);

            service = new ServiceHost(typeof(ChuongTrinhDaoTaoService));
            AddService(service);

            service = new ServiceHost(typeof(ComponentsService));
            AddService(service);

            service = new ServiceHost(typeof(ConfigsService));
            AddService(service);

            service = new ServiceHost(typeof(CTTinhDiemMonHocService));
            AddService(service);

            service = new ServiceHost(typeof(CTTinhDiemMonHocChiTietService));
            AddService(service);

            service = new ServiceHost(typeof(DangKyHocPhanService));
            AddService(service);

            service = new ServiceHost(typeof(DanhHieuKhenThuongService));
            AddService(service);

            service = new ServiceHost(typeof(DanhSachCamThiService));
            AddService(service);

            service = new ServiceHost(typeof(DanhSachDeNghiLuuBanService));
            AddService(service);

            service = new ServiceHost(typeof(DanhSachDinhChiHocService));
            AddService(service);

            service = new ServiceHost(typeof(DanhSachHocBongService));
            AddService(service);

            service = new ServiceHost(typeof(DanhSachHocLaiService));
            AddService(service);

            service = new ServiceHost(typeof(DanTocService));
            AddService(service);

            service = new ServiceHost(typeof(DiemMonHocService));
            AddService(service);

            service = new ServiceHost(typeof(DiemRenLuyenService));
            AddService(service);

            service = new ServiceHost(typeof(DoiTuongTroCapService));
            AddService(service);

            service = new ServiceHost(typeof(DoiTuongTSService));
            AddService(service);


            service = new ServiceHost(typeof(GiaoVienService));
            AddService(service);

            service = new ServiceHost(typeof(GiayToSinhVienService));
            AddService(service);

            service = new ServiceHost(typeof(HeDaoTaoService));
            AddService(service);

            service = new ServiceHost(typeof(HinhThucKyLuatService));
            AddService(service);

            service = new ServiceHost(typeof(HocKyService));
            AddService(service);

            service = new ServiceHost(typeof(HoSoService));
            AddService(service);

            service = new ServiceHost(typeof(HoSoChiTietService));
            AddService(service);


            service = new ServiceHost(typeof(KhenThuongSinhVienService));
            AddService(service);

            service = new ServiceHost(typeof(KhoaService));
            AddService(service);

            service = new ServiceHost(typeof(KhoaHocService));
            AddService(service);

            service = new ServiceHost(typeof(KhoanTienService));
            AddService(service);

            service = new ServiceHost(typeof(KhoanTienNhapTruongService));
            AddService(service);

            service = new ServiceHost(typeof(KhuNhaService));
            AddService(service);

            service = new ServiceHost(typeof(KhuVucService));
            AddService(service);

            service = new ServiceHost(typeof(KieuHuongTroCapService));
            AddService(service);

            service = new ServiceHost(typeof(KyLuatSinhVienService));
            AddService(service);

            service = new ServiceHost(typeof(KyThiService));
            AddService(service);


            service = new ServiceHost(typeof(LichHocLopTinChiService));
            AddService(service);

            service = new ServiceHost(typeof(LoaiDiemService));
            AddService(service);

            service = new ServiceHost(typeof(LoaiDoiTuongTroCapService));
            AddService(service);

            service = new ServiceHost(typeof(LoaiGiayToService));
            AddService(service);

            service = new ServiceHost(typeof(LoaiThietBiService));
            AddService(service);

            service = new ServiceHost(typeof(LopService));
            AddService(service);

            service = new ServiceHost(typeof(LopSinhVienService));
            AddService(service);

            service = new ServiceHost(typeof(LopTinChiService));
            AddService(service);

            service = new ServiceHost(typeof(LyDoCamThiService));
            AddService(service);

            service = new ServiceHost(typeof(LyLichSinhVienService));
            AddService(service);

            service = new ServiceHost(typeof(MenuRoleService));
            AddService(service);

            service = new ServiceHost(typeof(MenusService));
            AddService(service);

            service = new ServiceHost(typeof(ModulesService));
            AddService(service);

            service = new ServiceHost(typeof(MonHocService));
            AddService(service);

            service = new ServiceHost(typeof(MonHocSuDungThietBiService));
            AddService(service);

            service = new ServiceHost(typeof(MonThiService));
            AddService(service);


            service = new ServiceHost(typeof(MucHocBongService));
            AddService(service);

            service = new ServiceHost(typeof(NamHocService));
            AddService(service);

            service = new ServiceHost(typeof(NewsService));
            AddService(service);

            service = new ServiceHost(typeof(NganhHocService));
            AddService(service);

            service = new ServiceHost(typeof(PhanCongGiangDayService));
            AddService(service);

            service = new ServiceHost(typeof(PhanNganhSinhVienService));
            AddService(service);

            service = new ServiceHost(typeof(PhongHocService));
            AddService(service);

            service = new ServiceHost(typeof(PhongThiService));
            AddService(service);


            service = new ServiceHost(typeof(QuanHeHocPhanService));
            AddService(service);

            service = new ServiceHost(typeof(QuanHuyenService));
            AddService(service);

            service = new ServiceHost(typeof(QuocGiaService));
            AddService(service);

            service = new ServiceHost(typeof(RolesService));
            AddService(service);

            service = new ServiceHost(typeof(SinhVienService));
            AddService(service);

            service = new ServiceHost(typeof(SinhVienHocKyService));
            AddService(service);

            service = new ServiceHost(typeof(SinhVienLopTinChiService));
            AddService(service);

            service = new ServiceHost(typeof(SinhVienMonHocService));
            AddService(service);

            service = new ServiceHost(typeof(SinhVienNamHocService));
            AddService(service);

            service = new ServiceHost(typeof(SinhVienTrungTuyenService));
            AddService(service);

            service = new ServiceHost(typeof(SoCoSinhVienService));
            AddService(service);

            service = new ServiceHost(typeof(SoCoSinhVienChiTietService));
            AddService(service);

            service = new ServiceHost(typeof(SoNoSinhVienService));
            AddService(service);

            service = new ServiceHost(typeof(SoNoSinhVienChiTietService));
            AddService(service);


            service = new ServiceHost(typeof(SyncLogsService));
            AddService(service);

            service = new ServiceHost(typeof(SyncTablesService));
            AddService(service);

            service = new ServiceHost(typeof(ThangDanhGiaService));
            AddService(service);

            service = new ServiceHost(typeof(ThietBiKhuNhaService));
            AddService(service);

            service = new ServiceHost(typeof(ThietBiPhongHocService));
            AddService(service);

            service = new ServiceHost(typeof(ThiSinhMonThiService));
            AddService(service);

            service = new ServiceHost(typeof(ThuTrongTuanService));
            AddService(service);

            service = new ServiceHost(typeof(TietHocService));
            AddService(service);

            service = new ServiceHost(typeof(TinhThanhService));
            AddService(service);

            service = new ServiceHost(typeof(TonGiaoService));
            AddService(service);

            service = new ServiceHost(typeof(TrangThaiService));
            AddService(service);


            service = new ServiceHost(typeof(TrangThaiSinhVienService));
            AddService(service);

            service = new ServiceHost(typeof(TrungTamDaoTaoService));
            AddService(service);

            service = new ServiceHost(typeof(TuanHocService));
            AddService(service);

            service = new ServiceHost(typeof(UserRoleService));
            AddService(service);

            service = new ServiceHost(typeof(UsersService));
            AddService(service);


            service = new ServiceHost(typeof(XepLoaiPhoThongService));
            AddService(service);

            service = new ServiceHost(typeof(XepLoaiTongKetService));
            AddService(service);


            service = new ServiceHost(typeof(DiemDanhSinhVienService));
            AddService(service);

            service = new ServiceHost(typeof(SinhVienNghiHocService));
            AddService(service);


            service = new ServiceHost(typeof(DanhSachBaoLuuService));
            AddService(service);

            AddSMSService();

        }
        private void AddSMSService()
        {
            ServiceHost service = new ServiceHost(typeof(SMSService));
            AddService(service);
        }

        public void CloseServices()
        {
            foreach (ServiceHost service in listServices)
            {
                service.Close();
                //progress.Increment(1);
                //Application.DoEvents();
            }
            listServices.Clear();
        }
    }
}
